const install = (Vue, vm) => {
	// --------------------登录注册相关--------------------
	const login = {
		// 微信小程序静默登录
		wxMpSilenceLogin: (params = {}) => vm.$request.post('/auth/wechat/mp/login', params, {
			// 不执行全局错误处理
			handleError: false
		})
	}
    // 基础模块
    const common = {
        // banner and notice
        index: (params = {}) => vm.$request.get('/api/mp/common/index', params),
        noticePage: (params = {}) => vm.$request.get('/api/mp/common/notice-page', params),
        noticeDetail: (params = {}) => vm.$request.get('/api/mp/common/notice-detail', params),
    }
    // 钱包模块
    const wallet = {
        // 用户钱包信息
        myWallet: (params = {}) => vm.$request.post('/api/wallet/myWallet', params),
        // 用户钱包收入支出记录
        walletRecord: (params = {}) => vm.$request.post('/api/wallet/walletRecord', params),
    }
    // 授权接口模块
	const auth = {
        // 微信小程序授权注册
        wxMpAuth: (params = {}) => vm.$request.post('/auth/wechat/mp/auth', params),
        // 微信小程序短信注册
        wxMpSms: (params = {}) => vm.$request.post('/auth/wechat/sms', params),
		// 微信公众号权限授权
		wxPublicPermissionAuth: (params = {}) => vm.$request.post('/auth/appBind', params),
	}
	const user = {
		// 用户信息
		userInfo: (params = {}) => vm.$request.post('/api/mp/core/member/info', params),
		// 更新用户信息
		updateUserInfo: (params = {}) => vm.$request.post('/api/member/update', params),
		// 更新手机号码
		updatePhone: (params = {}) => vm.$request.post('/api/member/updatePhone', params),
		code: (params = {}) => vm.$request.post('/api/mp/core/member/code', params),
		shareCode: (params = {}) => vm.$request.post('/api/mp/core/member/share-code', params),
	}
    const area = {
		schoolList: (params = {}) => vm.$request.get('/api/mp/area/schoolList', params),
		buildingList: (params = {}) => vm.$request.get('/api/mp/area/buildingList', params),
    }
    const station = {
		list: (params = {}) => vm.$request.get('/api/mp/station/list', params),
    }
    const dormitory = {
		list: (params = {}) => vm.$request.get('/api/mp/core/dormitory/list', params),
		edit: (params = {}) => vm.$request.json('/api/mp/core/dormitory/edit', params),
		info: (params = {}) => vm.$request.get('/api/mp/core/dormitory/info', params),
		def: (params = {}) => vm.$request.get('/api/mp/core/dormitory/default', params),
    }
    const order = {
		prices: (params = {}) => vm.$request.get('/api/mp/core/price/list', params),
		page: (params = {}) => vm.$request.get('/api/mp/core/order/page', params),
		createOrder: (params = {}) => vm.$request.json('/api/mp/core/order/createOrder', params),
        info: (params = {}) => vm.$request.get('/api/mp/core/order/info', params),
        wechatPay: (params = {}) => vm.$request.get('/api/mp/core/order/wechat-pay', params),
        refresh: (params = {}) => vm.$request.get('/api/mp/core/order/refresh', params),
        cancel: (params = {}) => vm.$request.get('/api/mp/core/order/cancel', params),
    }
	// --------------------工具相关------------------------
	const util = {
		init: (params = {}) => vm.$request.post('/api/mp/common/init', params),
		// 获取上传签名
		uploadSign: (params = {}) => vm.$request.post('/api/comm/ossSign', params),
		// 上传文件
		uploadFile: (params = {}) => vm.$request.post('/api/comm/uploadFile', params),
		// 获取验证码
		getCode: (params = {}) => vm.$request.post('/auth/getCode', params),
		// 日志记录
		saveOperTime: (params = {}) => vm.$request.post('/api/member/saveOperTime', params),
        // 获取用户注册协议
        userAgreement: (params = {}) => vm.$request.post('/api/come/config/agree', params),
	}
    // 活动
    const activity = {
        page: (params = {}) => vm.$request.get('/api/mp/activity/page', params),
        detail: (params = {}) => vm.$request.get('/api/mp/activity/detail', params),
        registration: (params = {}) => vm.$request.get('/api/mp/activity/core/registration', params),
        register: (params = {}) => vm.$request.post('/api/mp/activity/core/register', params),
    }
    // 兑换券
    const voucher = {
        page: (params = {}) => vm.$request.get('/api/mp/voucher/page', params),
        detail: (params = {}) => vm.$request.get('/api/mp/voucher/detail', params),
		createOrder: (params = {}) => vm.$request.post('/api/mp/core/voucher/create-order', params),
        wechatPay: (params = {}) => vm.$request.get('/api/mp/core/voucher/wechat-pay', params),
        refresh: (params = {}) => vm.$request.get('/api/mp/core/voucher/refresh', params),
		orderPage: (params = {}) => vm.$request.get('/api/mp/core/voucher/order-page', params),
		orderDetail: (params = {}) => vm.$request.get('/api/mp/core/voucher/order-detail', params),
        cancel: (params = {}) => vm.$request.get('/api/mp/core/voucher/cancel', params),
    }
    // 优惠券
    const coupon = {
        moduleUnused: (params = {}) => vm.$request.get('/api/mp/core/coupon/module-unused', params),
        takeRecordPage: (params = {}) => vm.$request.get('/api/mp/core/coupon/take-record-page', params),
    }

	Vue.prototype.$api = {
		auth,
		user,
		util,
		login,
        common,
        wallet,
        area,
        station,
        dormitory,
        order,
        activity,
        voucher,
        coupon,
	};
}

export default {
	install
}
